]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionPrefs: Support uninstalling user extensions
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 30 Nov 2019 05:06:08 +0000 (06:06 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 3 Feb 2020 18:11:21 +0000 (19:11 +0100)
This is functionality currently provided by GNOME Software, and
which the new Extensions app should (and easily can) provide.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1968

js/extensionPrefs/main.js
js/extensionPrefs/ui/extension-row.ui

index e2babfe62f23bd71690f647bf76a4a4d59aa2cd4..bb1e46eaf3e2655034129273769c85aba84a787f 100644 (file)
@@ -12,7 +12,7 @@ const Config = imports.misc.config;
 const ExtensionUtils = imports.misc.extensionUtils;
 const { loadInterfaceXML } = imports.misc.fileUtils;
 
-const { ExtensionState } = ExtensionUtils;
+const { ExtensionState, ExtensionType } = ExtensionUtils;
 
 const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
 const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
@@ -119,6 +119,28 @@ var ExtensionsWindow = GObject.registerClass({
         return this.application.shellProxy;
     }
 
+    uninstall(uuid) {
+        let row = this._findExtensionRow(uuid);
+
+        let dialog = new Gtk.MessageDialog({
+            transient_for: this,
+            modal: true,
+            text: _('Remove “%s”?').format(row.name),
+            secondary_text: _('If you remove the extension, you need to return to download it if you want to enable it again'),
+        });
+
+        dialog.add_button(_('Cancel'), Gtk.ResponseType.CANCEL);
+        dialog.add_button(_('Remove'), Gtk.ResponseType.ACCEPT)
+            .get_style_context().add_class('destructive-action');
+
+        dialog.connect('response', (dlg, response) => {
+            if (response === Gtk.ResponseType.ACCEPT)
+                this._shellProxy.UninstallExtensionRemote(uuid);
+            dialog.destroy();
+        });
+        dialog.present();
+    }
+
     openPrefs(uuid) {
         if (!this._loaded)
             this._startupUuid = uuid;
@@ -517,6 +539,13 @@ var ExtensionRow = GObject.registerClass({
         });
         this._actionGroup.add_action(action);
 
+        action = new Gio.SimpleAction({
+            name: 'uninstall',
+            enabled: this.type === ExtensionType.PER_USER,
+        });
+        action.connect('activate', () => this.get_toplevel().uninstall(this.uuid));
+        this._actionGroup.add_action(action);
+
         action = new Gio.SimpleAction({
             name: 'enabled',
             state: new GLib.Variant('b', false),
@@ -574,6 +603,10 @@ var ExtensionRow = GObject.registerClass({
         return this._extension.hasPrefs;
     }
 
+    get type() {
+        return this._extension.type;
+    }
+
     get creator() {
         return this._extension.metadata.creator || '';
     }
index 0ec50802ea58220f59365ff7422f55237470136f..c4f4e60507ff8bdde4d0912cebb49b1805b2e4da 100644 (file)
                     <property name="top_attach">3</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkButton" id="removeButton">
+                    <property name="visible"
+                              bind-source="removeButton"
+                              bind-property="sensitive"
+                              bind-flags="sync-create"/>
+                    <property name="no_show_all">True</property>
+                    <property name="label" translatable="yes">Remove…</property>
+                    <property name="action_name">row.uninstall</property>
+                    <property name="hexpand">True</property>
+                    <property name="halign">end</property>
+                    <property name="valign">end</property>
+                    <style>
+                      <class name="destructive-action"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">3</property>
+                  </packing>
+                </child>
               </object>
             </child>
           </object>